var async = require('async');

/**
 * 通用的Cache数据存储与设置方法
 * @param keyParam
 * @param valueParam
 * @param expireSeconds
 */
exports.cacheSet = function (keyParam, valueParam, callback, expireSeconds) {
    //如果是memCache
    if (enableCache == 'memCache') {
        cacheClient.set(keyParam, valueParam, callback, expireSeconds);
    }
    //如果是redis,其expired的设定需要另外一个方法
    else {
        cacheClient.set(keyParam, valueParam, callback);
        cacheClient.expire(keyParam, expireSeconds);
    }
};

/**
 * 通用的cache值获取方法
 * @param keyParam
 */
exports.cacheGet = function (keyParam, callback) {
    cacheClient.get(keyParam, callback);
}

/**
 * 通用的cache删除方法
 * @param keyParam
 * @param callback
 */
exports.cacheDelete = function (keyParam, callback) {
    if (enableCache == 'memCache') {
        cacheClient.delete(keyParam, callback);
    } else {
        cacheClient.del(keyParam, callback);
    }
}


